package edu.bu.manateem.msg.model.isotope;

public class ResolvingPowerBinController implements BinController {

	long resolvingPower;

	public ResolvingPowerBinController(long resolvingPower) {
		this.resolvingPower = resolvingPower;
	}

	public boolean bin(Peak lower, Peak higher) {
		if (higher == null) {
			return false;
		}
		//double leftWidthOfHigher = higher.getMass() - halfWidth(higher.getMass());
		//double rightWidthOfLower = lower.getMass() + halfWidth(lower.getMass());
		//return ((leftWidthOfHigher - rightWidthOfLower) < ROUNDING_MAX_DIFF);
		double maxDiff = IsotopeUtils.strongerIsotope(lower, higher).getMass() / resolvingPower;
		return MassDiffBinController.bin(lower, higher, maxDiff);
	}

	double halfWidth(double mass) {
		return mass / resolvingPower / 2;
	}
}

